# Makefile

# Compiler
CC = gcc

# Compiler flags
CFLAGS = -Wall -g

# Target executable
TARGET_EXEC = main

# Static library (already exists)
TARGET_LIB = ./addFunc/lib/libadd.a

# Source files
SRCS = main.c

# Object files
OBJS = $(SRCS:.c=.o)

# Default target
all: $(TARGET_EXEC)

# Build the executable and link with the static library
$(TARGET_EXEC): $(OBJS) $(TARGET_LIB)
	$(CC) $(CFLAGS) -o $@ $(OBJS) -L./addFunc/lib -ladd

# Compile source files into object files
%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@ -I./addFunc

# Prevent make from trying to build the static library
$(TARGET_LIB):
	@echo "Using existing static library: $(TARGET_LIB)"

# Clean up build artifacts
clean:
	rm -f $(OBJS) $(TARGET_EXEC)

.PHONY: all clean $(TARGET_LIB)

